#ifndef C_LOADTHREAD_H
#define C_LOADTHREAD_H

#include <QThread>
#include "datasource/C_DBDataSourceFactory.h"
using namespace onegis::psde::datasource;
#include <protobuf/PbFormatData.pb.h>
using namespace onegis::protobuf::model;
#include <QVector>

class DomainNode;
class ObjectNode;

class C_LoadThread : public QThread
{
	Q_OBJECT

public:
	C_LoadThread(QObject *parent);
	~C_LoadThread();

	void setCatalog(DBDataSourcePtr pDBDataSource, DomainNode* pNodeDomain);

	void loadObject(DBDataSourcePtr pDBDataSource, ObjectNode* pNodeObject);

private slots:

	void onLoadObjectFinish();

signals:

	void setProgressValue(int);

	void setProgressMax(int);

	void objectVersionLoaded(void*, long long, int);

	void objectLoadedForManager(QVector<PbSObject*>);

protected:

	void run();

private:

	bool writeModelToLocal(PbSObject* pObject, ModelOpClassPtr pModelClass);

private:

	//CatalogClassPtr m_pCatalog;
	DomainNode* m_pNodeDomain;
	enum LoadMode{
		LOAD_DOMAIN,
		LOAD_OBJECT
	};
	LoadMode m_loadMode;
	//SObjectClassPtr m_pObjectOp;
	DBDataSourcePtr m_pDBDataSource;
	ObjectNode* m_pNodeObject;
};

#endif // C_LOADTHREAD_H
